<template>
	<uni-popup type="bottom" ref="input">
		<view class="bg-white flex align-center px-3" style="height: 120rpx;">
			<input type="text" v-model="content" class="border rounded flex-1 px-3 font-md" placeholder="说点什么..." style="height: 80rpx;" />
			<view class="flex align-center justify-center py-2 px-2 ml-3 rounded" @click="submit" :class="content === '' ? 'bg-main-disabled' : 'bg-main'">
				<text class="font text-white">发送</text>
			</view>
		</view>
	</uni-popup>
</template>

<script>
	export default {
		data() {
			return {
				content: ""
			}
		},
		methods: {
			close() {
				this.$refs.input.close()
			},
			open() {
				this.$refs.input.open()
			},
			submit() {
				this.content = this.content.trim()
				if(this.content == "") {
					uni.showToast({
						title: '说点什么...'
					});
					return
				}
				this.$emit('sendBarrage', {
					id: Math.random() * 100,
					name: "大强",
					content: this.content
				})
				this.content = ""
				this.$refs.input.close()
			}
		}
	}
</script>

<style lang="scss" scoped>
	
</style>
